/*  This file is part of -_-.

    -_- is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    -_- is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with -_-.  If not, see <http://www.gnu.org/licenses/>.

    Copyright 2012-2013 Oliver Katz */

#ifndef __COMMON_HOMOGENIZER_H
#define __COMMON_HOMOGENIZER_H

#include "data.h"
#include "types/vector.h"
#include "types/string.h"
#include "types/assoc.h"
#include "types/pair.h"

void z_homogenize(z_data **d); //method: homogenizes 'd'
void z_rebase(z_data *d, void *a, void *b); //method: assigns a new base to 'd'
//argof z_rebase: void *a: old memory block pointer
//argof z_rebase: void *b: new memory block pointer

/// Dynamic data structures are very heterogenous (stored in many different memory locations). z_homogenize duplicates all of this data in one homogeneous (continuous) memory block. This is useful for transmission purposes. After transmitting the data block, the pointers within the data block are all relative to the beginning of the old data block and must be rebased so that they are correct according to the new beginning of the data block. This is done with z_rebase.

#endif
